# -*- coding: utf-8 -*-
"""
@Time ： 2022/12/27 10:46
@Auth ： jiraWu
@File ：_data.py
@IDE ：PyCharm
@Motto:人生苦短，我学Python

"""

"""
数据整理类
"""
from typing import Union


class Data:
    def __init__(self, **kwargs):
        """
        初始化
        :param kwargs: 列数据
        """
        self.kwargs = kwargs

    def __str__(self):
        return f"{str(self.kwargs)}"

    def __setitem__(self, key, val):
        self.kwargs[key] = val

    def __getitem__(self, key):
        if key in self.kwargs:
            return self.kwargs[key]
        else:
            r = Data()
            self.__setitem__(key, r)
            return r


if __name__ == '__main__':
    d1 = Data(a=1, b=2, c=3)
    d2 = Data(a=4, b=5, c=6)
    data_lis = [d1, d2]
    print(type(data_lis))
    print(data_lis)
    print(d2)
